package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         198,
		Discription: "线性打家劫舍",
		Level:       2,
		Labels: map[string]int{
			"动态规划": 1,
			"有限状态机": 1,
			"空间降维": 1,
		},
	})
}

func Rob(nums []int) int {
	coolDown := 0
	stolen := nums[0]
	for i := 1; i < len(nums); i++ {
		tempCooldown := max(coolDown, stolen)
		tempStolen := coolDown + nums[i]
		coolDown = tempCooldown
		stolen = tempStolen
	}

	return max(coolDown, stolen)
}
